package com.ruoyi.web.controller.youtobe;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.youtobe.domain.YoutobeChannelInfo;
import com.ruoyi.youtobe.service.IYoutobeChannelInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Youtobe频道信息Controller
 *
 * @author ruoyi
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/youtobe/channel")
public class YoutobeChannelInfoController extends BaseController {
    @Autowired
    private IYoutobeChannelInfoService youtobeChannelInfoService;

    /**
     * 查询Youtobe频道信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(YoutobeChannelInfo youtobeChannelInfo) {
        startPage();
        List<YoutobeChannelInfo> list = youtobeChannelInfoService.selectYoutobeChannelInfoList(youtobeChannelInfo);
        return getDataTable(list);
    }
    @GetMapping("/allList")
    public AjaxResult allList(YoutobeChannelInfo youtobeChannelInfo) {
        return AjaxResult.success( youtobeChannelInfoService.selectYoutobeChannelInfoList(youtobeChannelInfo));
    }
    /**
     * 导出Youtobe频道信息列表
     */
    @Log(title = "Youtobe频道信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YoutobeChannelInfo youtobeChannelInfo) {
        List<YoutobeChannelInfo> list = youtobeChannelInfoService.selectYoutobeChannelInfoList(youtobeChannelInfo);
        ExcelUtil<YoutobeChannelInfo> util = new ExcelUtil<YoutobeChannelInfo>(YoutobeChannelInfo.class);
        util.exportExcel(response, list, "Youtobe频道信息数据");
    }

    /**
     * 获取Youtobe频道信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(youtobeChannelInfoService.selectYoutobeChannelInfoById(id));
    }

    /**
     * 新增Youtobe频道信息
     */
    @Log(title = "Youtobe频道信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YoutobeChannelInfo youtobeChannelInfo) {
        return toAjax(youtobeChannelInfoService.insertYoutobeChannelInfo(youtobeChannelInfo));
    }

    /**
     * 修改Youtobe频道信息
     */
    @Log(title = "Youtobe频道信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YoutobeChannelInfo youtobeChannelInfo) {
        return toAjax(youtobeChannelInfoService.updateYoutobeChannelInfo(youtobeChannelInfo));
    }

    /**
     * 删除Youtobe频道信息
     */
    @Log(title = "Youtobe频道信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(youtobeChannelInfoService.deleteYoutobeChannelInfoByIds(ids));
    }
}
